package lion.framework.core.db.anno;

import java.lang.annotation.Annotation;

import lion.dev.lang.MapJ;
import lion.framework.core.anno.AnnoProcessor;
import lion.framework.core.anno.AnnotationProcessorManager;
import lion.framework.core.anno.IAnnotationProcessor;
import lion.framework.core.db.paging.ISQLPaging;
import lion.framework.core.db.paging.SQLPagingFactory;

@AnnoProcessor(SQLPaging.class)
public class SQLPagingAnnoProcessor implements IAnnotationProcessor {

	@Override
	public void processe(MapJ ctx, Annotation anno) throws Exception {

		Class<?> clazz = ctx.getE(AnnotationProcessorManager.ANNO_CONTEXT_TARGET);
		if (!ISQLPaging.class.isAssignableFrom(clazz)) { return; }

		SQLPaging p = (SQLPaging) anno;

		for (String type : p.value()) {
			SQLPagingFactory.regist(type, (ISQLPaging) clazz.newInstance());
		}
	}
}
